export default {
  add(state, item) {
    let flag = false
    this.state.shoplist.forEach(list => {
      if (list.id == item.id) {
        flag = true
        list.num = list.num + item.num
      }
    })
    if (flag == false) {
      state.shoplist.push(item)
    }
  },

  del(state, item) {
    // console.log(item);
    this.state.shoplist.forEach((list, index) => {
      if (list.id == item.id) {
        this.state.shoplist.splice(index, 1)
      }
    })
  },

  count(state, sum) {

    // console.log(sum);
    this.state.shoplist.forEach(list => {
      if (list.id == sum.id) {
        list.num = sum.val
      }
    })
  }

}